package com.frikinet.lifeguard.gui;

import java.awt.BorderLayout;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JPanel;

import com.frikinet.lifeguard.App;
import com.frikinet.lifeguard.events.PostSelectedEvent;
import com.frikinet.lifeguard.events.PostSelectedListener;

public class PostHtmlPanel extends JPanel implements PostSelectedListener
{
	private static final long serialVersionUID = 1L;
	
	private TemplateHtmlPanel htmlPanel;
	
	public PostHtmlPanel()
	{
		super(new BorderLayout());
		
		App.events.addPostSelectedListener(this);
		
		buildGUI();
	}
	
	private void buildGUI()
	{
		htmlPanel = new TemplateHtmlPanel();
		add(htmlPanel, BorderLayout.CENTER);
	}

	@Override
	public void postSelected(PostSelectedEvent event)
	{
		Map<String, Object> context = new HashMap<String, Object>();
		context.put("post", event.getPost());
		htmlPanel.navigate("post", context);
	}
}
